package leetcode.code2027;

public class Solution {
	public int minimumMoves(String s) {
		int ans = 0;
		char[] cs = s.toCharArray();
		for (int i = 0, cnt = 0; i < s.length(); i++) {
			char c = cs[i];
			if (c == 'X') {
				if (cnt == 0) {
					ans++;
					cnt = 3;
				}
				cnt--;
			} else if (cnt > 0 && cnt < 3) {
				cnt--;
			}
		}
		return ans;
	}
}
